import { Route, Redirect } from 'react-router-dom'
import { getToken } from '@/utils/auth.js'
import { message } from 'antd'
export default function AuthRoute(props) {
  // console.log(props)
  const { component: Com, ...otherProps } = props
  return (
    <Route
      {...otherProps}
      render={() => {
        if (getToken()) {
          return <Com></Com>
        } else {
          message.warning('请先登录')
          return <Redirect to="/login"></Redirect>
        }
      }}
    ></Route>
  )
}
